<?php
/**
 * Created by PhpStorm.
 * User: jimmyhsu
 * Date: 2016/10/24
 * Time: 17:29
 */
include ("checkvalid.php");
$name = $_POST['username'];
$type = $_POST['type'];
if ($type == 0) { //all
    $sql = "select * from dwtb where status=1 order by id desc";
    $rs = mysql_query($sql);
} else { //specified type
    $type = $type - 1;
    $sql = "select * from dwtb where status=1 and type=$type order by id desc";
    $rs = mysql_query($sql);
}
$rsArr = array();
while ($row = mysql_fetch_array($rs)) {
    
    array_push($rsArr, array("userid"=>$row['userid'], "title"=>urlencode($row['title']), "id"=>$row['id'], 
        "content"=>urlencode($row['content']), "price"=>$row['price'], "type"=>$row['type'], "lat"=>$row['lat'],
        "longt"=>$row['longt'], "time"=>$row['time'], "username"=>urlencode($row['username']), "imageurls"=>$row['imageurls'], "contact"=>$row['contact']));
}
echo urldecode(json_encode($rsArr));